/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Nihongo
 * Copyright (C) Massimiliano Maniscalco 2011, 2012 <massimiliano@massiLinuxBook>
 * 
Nihongo is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Nihongo is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "result_test_kanji.h"
#include "kanji.h"

bool ResultTestKanji::
present_window ( void )
{
	_resultList->get_column ( 0 )->set_title ( "漢字" );
	_resultList->get_column ( 1 )->set_title ( "Radicale" );
	_resultList->get_column ( 2 )->set_title ( "Significato" );
	_resultList->get_column ( 3 )->set_title ( "Valutazione" );
	_resultList->set_model(_kanjiListStore);
	bool shouldPresent = ( load_item_in_tree_view () > 0 );
	if ( shouldPresent )
		_resultWin->present ();
	return shouldPresent;
}

unsigned int ResultTestKanji::
load_item_in_tree_view ( void )
{
	_kanjiListStore->clear();
	list<Kanji>::iterator iter = _kanji->begin();
	list<Kanji>::iterator iter_end = _kanji->end();
	unsigned int n = 0;
	while (iter != iter_end)
	{
		bool _match = true;
		if ( !iter->get_errata () )
			_match = false;
		if ( _match )
		{
			Gtk::TreeModel::iterator iterRow = _kanjiListStore->append();
			Gtk::TreeModel::Row row = *iterRow;
			row[_kanjiListColumns->kanji] = iter->get_kanji();
			row[_kanjiListColumns->radicale] = iter->get_radicale();
			row[_kanjiListColumns->significato] = iter->get_significato();
			row[_kanjiListColumns->valutazione] = iter->get_valutazione ( _modo );
			n++;
		}
		iter++;
	}
	return n;
}
